<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Using Exceptions - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.exception.using.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.exception.using.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.exception.html">Zend_Exception</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.exception.html">Zend_Exception</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.exception.basic.html">Basic usage</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.exception.using" class="section"><div class="info"><h1 class="title">Using Exceptions</h1></div>
    

    <p class="para">
        <span class="classname">Zend_Exception</span> is simply the base class for all exceptions thrown
        within Zend Framework.
    </p>

    <div class="example" id="zend.exception.using.example"><div class="info"><p><b>Example #1 Catching an Exception</b></p></div>
        

        <div class="example-contents"><p>
            The following code listing demonstrates how to catch an exception thrown in a Zend
            Framework class:
        </p></div>

        <pre class="programlisting brush: php">
try {
    // Calling Zend_Loader::loadClass() with a non-existant class will cause
    // an exception to be thrown in Zend_Loader:
    Zend_Loader::loadClass(&#039;nonexistantclass&#039;);
} catch (Zend_Exception $e) {
    echo &quot;Caught exception: &quot; . get_class($e) . &quot;\n&quot;;
    echo &quot;Message: &quot; . $e-&gt;getMessage() . &quot;\n&quot;;
    // Other code to recover from the error
}
</pre>

    </div>

    <p class="para">
        <span class="classname">Zend_Exception</span> can be used as a catch-all exception class in a
        catch block to trap all exceptions thrown by Zend Framework classes. This can
        be useful when the program can not recover by catching a specific exception type.
    </p>

    <p class="para">
        The documentation for each Zend Framework
        component and class will contain specific information on which methods
        throw exceptions, the circumstances that cause an exception to be thrown,
        and the various exception types that may be thrown.
    </p>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.exception.html">Zend_Exception</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.exception.html">Zend_Exception</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.exception.basic.html">Basic usage</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.exception.html">Zend_Exception</a></li>
  <li class="active"><a href="zend.exception.using.html">Using Exceptions</a></li>
  <li><a href="zend.exception.basic.html">Basic usage</a></li>
  <li><a href="zend.exception.previous.html">Previous Exceptions</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>